package com.focusai.efairy.model.request;

import com.focusai.efairy.model.manager.CacheManager;
import com.focusai.efairy.network.Response;
import com.focusai.efairy.network.exception.ParseException;
import com.focusai.efairy.network.request.base.DeletePureJSONRequest;
import com.focusai.efairy.network.utils.UrlUtils;
import com.focusai.efairy.utils.GsonHelper;
import com.google.gson.reflect.TypeToken;

import org.json.JSONException;

import java.util.List;
import java.util.Map;

/**
 * Created by luo_guangwen on 2017/9/18.
 */

public class DeleteAnnounceReqeust extends DeletePureJSONRequest<String> {
    public List<Long> announcement_id_list;

    public DeleteAnnounceReqeust(List<Long> announcement_id_list, Response.Listener<String> listener) {
        super(UrlUtils.createUrl("/appapi/announcement"), listener);
        this.announcement_id_list = announcement_id_list;
    }

    @Override
    protected String parse(String result) throws ParseException {
        return GsonHelper.getInstance().fromJson(result, new TypeToken<String>() {
        }.getType());
    }

    @Override
    public Map<String, String> getParams() throws JSONException {
        addParam("efairyuser_id", CacheManager.getUserId());
        addParam("access_token", CacheManager.getAccessToken());
        addParam("announcement_id_list", GsonHelper.getInstance().toJson(announcement_id_list));
        return super.getParams();
    }

    @Override
    public String getPureJSON() throws JSONException {
        return null;
    }

}
